//
//  HashTable.m
//  HashTableMapTableOrderedSet
//
//  Created by lvfeijun on 2021/5/21.
//

#import "HashTable.h"

@implementation HashTable
{
    NSHashTable *_hashTable;
}


+(instancetype)ShareInstace{
    static HashTable *obj = nil;
    static dispatch_once_t oneToken;
    dispatch_once(&oneToken, ^{
        obj= [[self alloc]init];
    });
    return obj;
}

-(instancetype)init{
    if (self = [super init]) {
        _hashTable = [NSHashTable weakObjectsHashTable];
    }
    return self;
}

-(void)addDelegate:(id)delegate{
    if (delegate) {
        [_hashTable addObject:delegate];
    }
}

-(NSArray *)delegates{
    return _hashTable.allObjects;
}

@end
